package com.mxdx.edu.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.mxdx.edu.dao.MaterialDao;
import com.mxdx.edu.service.IMaterialService;

/**
 * 课程资料service
 *
 * @author howie
 */
@Service
public class MaterialServiceImpl implements IMaterialService {

	@Resource
	private MaterialDao materialDao;
	
	@Override
	public List<Map<String, Object>> findListByMap(Map<String, Object> param) {
		return materialDao.findListByMap(param);
	}

	@Override
	public Integer materialStudentCountByMap(String studentId,String courseId,String semesterId,String materialId){
		Map<String, Object> param = new HashMap<>();

		param.put("studentId",studentId);
		param.put("courseId",courseId);
		param.put("semesterId",semesterId);
		param.put("materialId",materialId);

		return materialDao.materialStudentCountByMap(param) == null ? 0 : materialDao.materialStudentCountByMap(param);
	}

	@Override
	public int materialStudentSave(String id, String studentId, String courseId, String semesterId, String materialId, Date createDate, Date updateDate){
		Map<String, Object> param = new HashMap<>();

		param.put("id",id);
		param.put("studentId",studentId);
		param.put("courseId",courseId);
		param.put("semesterId",semesterId);
		param.put("materialId",materialId);
		param.put("createDate",createDate);
		param.put("updateDate",updateDate);

		return materialDao.materialStudentSave(param);
	}

	@Override
	public int materialStudentUpdate(String id,String studentId,String courseId,String semesterId,String materialId, Date updateDate){
		Map<String, Object> param = new HashMap<>();

		param.put("id",id);
		param.put("studentId",studentId);
		param.put("courseId",courseId);
		param.put("semesterId",semesterId);
		param.put("materialId",materialId);
		param.put("updateDate",updateDate);

		return materialDao.materialStudentUpdate(param);
	}

	@Override
	public int materialStudentDelete(String studentId,String courseId,String semesterId,String materialId){
		Map<String, Object> param = new HashMap<>();

		param.put("studentId",studentId);
		param.put("courseId",courseId);
		param.put("semesterId",semesterId);
		param.put("materialId",materialId);

		return materialDao.materialStudentDelete(param);
	}

	@Override
	public Integer materialCourseLimitByMap(String courseId,String packetId){
		Map<String, Object> param = new HashMap<>();

		param.put("courseId",courseId);
		param.put("packetId",packetId);

		return materialDao.materialCourseLimitByMap(param) == null ? 0 : materialDao.materialCourseLimitByMap(param);
	}
	

}
